home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / libcruft / ranlib / ranlib.fdoc < prev    next >
Text File  |  1996-07-19  |  61KB  |  871 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.                                      RANLIB
  13.  
  14.             Library of Fortran Routines for Random Number Generation
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.                        Full Documentation of Each Routine
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.                             Compiled and Written by:
  33.  
  34.                                  Barry W. Brown
  35.                                   James Lovato
  36.                                    
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.                      Department of Biomathematics, Box 237
  47.                      The University of Texas, M.D. Anderson Cancer Center
  48.                      1515 Holcombe Boulevard
  49.                      Houston, TX      77030
  50.  
  51.  
  52.  This work was supported by grant CA-16672 from the National Cancer Institute.
  53.  
  54. C**********************************************************************  
  55. C                                                                        
  56. C     SUBROUTINE ADVNST(K)                                               
  57. C               ADV-a-N-ce ST-ate                                        
  58. C                                                                        
  59. C     Advances the state  of  the current  generator  by 2^K values  and 
  60. C     resets the initial seed to that value.                             
  61. C                                                                        
  62. C     This is  a  transcription from   Pascal to  Fortran    of  routine 
  63. C     Advance_State from the paper                                       
  64. C                                                                        
  65. C     L'Ecuyer, P. and  Cote, S. "Implementing  a  Random Number Package 
  66. C     with  Splitting   Facilities."  ACM  Transactions  on Mathematical 
  67. C     Software, 17:98-111 (1991)                                         
  68. C                                                                        
  69. C                                                                        
  70. C                              Arguments                                 
  71. C                                                                        
  72. C                                                                        
  73. C     K -> The generator is advanced by2^K values                        
  74. C                                   INTEGER K                            
  75. C                                                                        
  76. C**********************************************************************  
  77. C**********************************************************************  
  78. C                                                                        
  79. C     REAL FUNCTION GENBET( A, B )                                       
  80. C               GeNerate BETa random deviate                             
  81. C                                                                        
  82. C                                                                        
  83. C                              Function                                  
  84. C                                                                        
  85. C                                                                        
  86. C     Returns a single random deviate from the beta distribution with    
  87. C     parameters A and B.  The density of the beta is                    
  88. C               x^(a-1) * (1-x)^(b-1) / B(a,b) for 0 < x < 1             
  89. C                                                                        
  90. C                                                                        
  91. C                              Arguments                                 
  92. C                                                                        
  93. C                                                                        
  94. C     A --> First parameter of the beta distribution                     
  95. C                         REAL A                                         
  96. C                                                                        
  97. C     B --> Second parameter of the beta distribution                    
  98. C                         REAL B                                         
  99. C                                                                        
  100. C                                                                        
  101. C                              Method                                    
  102. C                                                                        
  103. C                                                                        
  104. C     R. C. H. Cheng                                                     
  105. C     Generating Beta Variables with Nonintegral Shape Parameters         
  106. C     Communications of the ACM, 21:317-322  (1978)                      
  107. C     (Algorithms BB and BC)                                             
  108. C                                                                        
  109. C**********************************************************************  
  110. C**********************************************************************  
  111. C                                                                        
  112. C     REAL FUNCTION GENCHI( DF )                                         
  113. C                Generate random value of CHIsquare variable             
  114. C                                                                        
  115. C                                                                        
  116. C                              Function                                  
  117. C                                                                        
  118. C                                                                        
  119. C     Generates random deviate from the distribution of a chisquare      
  120. C     with DF degrees of freedom random variable.                        
  121. C                                                                        
  122. C                                                                        
  123. C                              Arguments                                 
  124. C                                                                        
  125. C                                                                        
  126. C     DF --> Degrees of freedom of the chisquare                         
  127. C            (Must be positive)                                          
  128. C                         REAL DF                                        
  129. C                                                                        
  130. C                                                                        
  131. C                              Method                                    
  132. C                                                                        
  133. C                                                                        
  134. C     Uses relation between chisquare and gamma.                         
  135. C                                                                        
  136. C**********************************************************************  
  137. C**********************************************************************  
  138. C                                                                        
  139. C     REAL FUNCTION GENEXP( AV )                                         
  140. C                                                                        
  141. C                    GENerate EXPonential random deviate                 
  142. C                                                                        
  143. C                                                                        
  144. C                              Function                                  
  145. C                                                                        
  146. C                                                                        
  147. C     Generates a single random deviate from an exponential              
  148. C     distribution with mean AV.                                         
  149. C                                                                        
  150. C                                                                        
  151. C                              Arguments                                 
  152. C                                                                        
  153. C                                                                        
  154. C     AV --> The mean of the exponential distribution from which         
  155. C            a random deviate is to be generated.                        
  156. C                              REAL AV                                   
  157. C                                                                        
  158. C     GENEXP <-- The random deviate.                                     
  159. C                              REAL GENEXP                               
  160. C                                                                        
  161. C                                                                        
  162. C                              Method                                    
  163. C                                                                        
  164. C                                                                        
  165. C     Renames SEXPO from TOMS as slightly modified by BWB to use RANF    
  166. C     instead of SUNIF.                                                  
  167. C                                                                        
  168. C     For details see:                                                   
  169. C                                                                        
  170. C               Ahrens, J.H. and Dieter, U.                              
  171. C               Computer Methods for Sampling From the                   
  172. C               Exponential and Normal Distributions.                    
  173. C               Comm. ACM, 15,10 (Oct. 1972), 873 - 882.                 
  174. C                                                                        
  175. C**********************************************************************  
  176. C**********************************************************************  
  177. C                                                                        
  178. C     REAL FUNCTION GENF( DFN, DFD )                                     
  179. C                GENerate random deviate from the F distribution         
  180. C                                                                        
  181. C                                                                        
  182. C                              Function                                  
  183. C                                                                        
  184. C                                                                        
  185. C     Generates a random deviate from the F (variance ratio)             
  186. C     distribution with DFN degrees of freedom in the numerator          
  187. C     and DFD degrees of freedom in the denominator.                     
  188. C                                                                        
  189. C                                                                        
  190. C                              Arguments                                 
  191. C                                                                        
  192. C                                                                        
  193. C     DFN --> Numerator degrees of freedom                               
  194. C             (Must be positive)                                         
  195. C                              REAL DFN                                  
  196. C      DFD --> Denominator degrees of freedom                            
  197. C             (Must be positive)                                         
  198. C                              REAL DFD                                  
  199. C                                                                        
  200. C                                                                        
  201. C                              Method                                    
  202. C                                                                        
  203. C                                                                        
  204. C     Directly generates ratio of chisquare variates                     
  205. C                                                                        
  206. C**********************************************************************  
  207. C**********************************************************************  
  208. C                                                                        
  209. C     REAL FUNCTION GENGAM( A, R )                                       
  210. C           GENerates random deviates from GAMma distribution            
  211. C                                                                        
  212. C                                                                        
  213. C                              Function                                  
  214. C                                                                        
  215. C                                                                        
  216. C     Generates random deviates from the gamma distribution whose        
  217. C     density is                                                         
  218. C          (A**R)/Gamma(R) * X**(R-1) * Exp(-A*X)                        
  219. C                                                                        
  220. C                                                                        
  221. C                              Arguments                                 
  222. C                                                                        
  223. C                                                                        
  224. C     A --> Location parameter of Gamma distribution                     
  225. C                              REAL A                                    
  226. C                                                                        
  227. C     R --> Shape parameter of Gamma distribution                        
  228. C                              REAL R                                    
  229. C                                                                        
  230. C                                                                        
  231. C                              Method                                    
  232. C                                                                        
  233. C                                                                        
  234. C     Renames SGAMMA from TOMS as slightly modified by BWB to use RANF   
  235. C     instead of SUNIF.                                                  
  236. C                                                                        
  237. C     For details see:                                                   
  238. C               (Case R >= 1.0)                                          
  239. C               Ahrens, J.H. and Dieter, U.                              
  240. C               Generating Gamma Variates by a                           
  241. C               Modified Rejection Technique.                            
  242. C               Comm. ACM, 25,1 (Jan. 1982), 47 - 54.                    
  243. C     Algorithm GD                                                       
  244. C                                                                        
  245. C               (Case 0.0 <= R <= 1.0)                                   
  246. C               Ahrens, J.H. and Dieter, U.                              
  247. C               Computer Methods for Sampling from Gamma,                
  248. C               Beta, Poisson and Binomial Distributions.                
  249. C               Computing, 12 (1974), 223-246/                           
  250. C     Adapted algorithm GS.                                              
  251. C                                                                        
  252. C**********************************************************************  
  253. C********************************************************************** 
  254. C                                                                       
  255. C     SUBROUTINE GENMN(PARM,X,WORK)                                     
  256. C              GENerate Multivariate Normal random deviate              
  257. C                                                                       
  258. C                                                                       
  259. C                              Arguments                                
  260. C                                                                       
  261. C                                                                       
  262. C     PARM --> Parameters needed to generate multivariate normal        
  263. C               deviates (MEANV and Cholesky decomposition of           
  264. C               COVM). Set by a previous call to SETGMN.                
  265. C                                                                       
  266. C               1 : 1                - size of deviate, P               
  267. C               2 : P + 1            - mean vector                      
  268. C               P+2 : P*(P+3)/2 + 1  - upper half of cholesky           
  269. C                                       decomposition of cov matrix     
  270. C                                             REAL PARM(*)              
  271. C                                                                       
  272. C     X    <-- Vector deviate generated.                                
  273. C                                             REAL X(P)                 
  274. C                                                                       
  275. C     WORK <--> Scratch array                                           
  276. C                                             REAL WORK(P)              
  277. C                                                                       
  278. C                                                                       
  279. C                              Method                                   
  280. C                                                                       
  281. C                                                                       
  282. C     1) Generate P independent standard normal deviates - Ei ~ N(0,1)  
  283. C                                                                       
  284. C     2) SETGMN uses Cholesky decomposition find A s.t. trans(A)*A = COV
  285. C                                                                       
  286. C     3) Generate trans(A)*E + MEANV ~ N(MEANV,COVM)                    
  287. C                                                                       
  288. C********************************************************************** 
  289. C**********************************************************************  
  290. C                                                                        
  291. C     REAL FUNCTION GENNCH( DF, XNONC )                                  
  292. C           Generate random value of Noncentral CHIsquare variable       
  293. C                                                                        
  294. C                                                                        
  295. C                              Function                                  
  296. C                                                                        
  297. C                                                                        
  298.                                                                          
  299. C     Generates random deviate  from the  distribution  of a  noncentral 
  300. C     chisquare with DF degrees  of freedom and noncentrality  parameter 
  301. C     XNONC.                                                             
  302. C                                                                        
  303. C                                                                        
  304. C                              Arguments                                 
  305. C                                                                        
  306. C                                                                        
  307. C     DF --> Degrees of freedom of the chisquare                         
  308. C            (Must be > 1.0)                                             
  309. C                         REAL DF                                        
  310. C                                                                        
  311. C     XNONC --> Noncentrality parameter of the chisquare                 
  312. C               (Must be >= 0.0)                                         
  313. C                         REAL XNONC                                     
  314. C                                                                        
  315. C                                                                        
  316. C                              Method                                    
  317. C                                                                        
  318. C                                                                        
  319. C     Uses fact that  noncentral chisquare  is  the  sum of a  chisquare 
  320. C     deviate with DF-1  degrees of freedom plus the  square of a normal 
  321. C     deviate with mean XNONC and standard deviation 1.                  
  322. C                                                                        
  323. C**********************************************************************  
  324. C**********************************************************************  
  325. C                                                                        
  326. C     REAL FUNCTION GENNF( DFN, DFD, XNONC )                             
  327. C           GENerate random deviate from the Noncentral F distribution   
  328. C                                                                        
  329. C                                                                        
  330. C                              Function                                  
  331. C                                                                        
  332. C                                                                        
  333. C     Generates a random deviate from the  noncentral F (variance ratio) 
  334. C     distribution with DFN degrees of freedom in the numerator, and DFD 
  335. C     degrees of freedom in the denominator, and noncentrality parameter 
  336. C     XNONC.                                                             
  337. C                                                                        
  338. C                                                                        
  339. C                              Arguments                                 
  340. C                                                                        
  341. C                                                                        
  342. C     DFN --> Numerator degrees of freedom                               
  343. C             (Must be >= 1.0)                                           
  344. C                              REAL DFN                                  
  345. C      DFD --> Denominator degrees of freedom                            
  346. C             (Must be positive)                                         
  347. C                              REAL DFD                                  
  348. C                                                                        
  349. C     XNONC --> Noncentrality parameter                                  
  350. C               (Must be nonnegative)                                    
  351. C                              REAL XNONC                                
  352. C                                                                        
  353. C                                                                        
  354. C                              Method                                    
  355. C                                                                        
  356. C                                                                        
  357. C     Directly generates ratio of noncentral numerator chisquare variate 
  358. C     to central denominator chisquare variate.                          
  359. C                                                                        
  360. C**********************************************************************  
  361. C**********************************************************************  
  362. C                                                                        
  363. C     REAL FUNCTION GENNOR( AV, SD )                                     
  364. C                                                                        
  365. C         GENerate random deviate from a NORmal distribution             
  366. C                                                                        
  367. C                                                                        
  368. C                              Function                                  
  369. C                                                                        
  370. C                                                                        
  371. C     Generates a single random deviate from a normal distribution       
  372. C     with mean, AV, and standard deviation, SD.                         
  373. C                                                                        
  374. C                                                                        
  375. C                              Arguments                                 
  376. C                                                                        
  377. C                                                                        
  378. C     AV --> Mean of the normal distribution.                            
  379. C                              REAL AV                                   
  380. C                                                                        
  381. C     SD --> Standard deviation of the normal distribution.              
  382. C                              REAL SD                                   
  383. C                                                                        
  384. C     GENNOR <-- Generated normal deviate.                               
  385. C                              REAL GENNOR                               
  386. C                                                                        
  387. C                                                                        
  388. C                              Method                                    
  389. C                                                                        
  390. C                                                                        
  391. C     Renames SNORM from TOMS as slightly modified by BWB to use RANF    
  392. C     instead of SUNIF.                                                  
  393. C                                                                        
  394. C     For details see:                                                   
  395. C               Ahrens, J.H. and Dieter, U.                              
  396. C               Extensions of Forsythe's Method for Random               
  397. C               Sampling from the Normal Distribution.                   
  398. C               Math. Comput., 27,124 (Oct. 1973), 927 - 937.            
  399. C                                                                        
  400. C                                                                        
  401. C**********************************************************************  
  402. C**********************************************************************  
  403. C                                                                        
  404. C    SUBROUTINE GENPRM( IARRAY, LARRAY )                                 
  405. C               GENerate random PeRMutation of iarray                    
  406. C                                                                        
  407. C                                                                        
  408. C                              Arguments                                 
  409. C                                                                        
  410. C                                                                        
  411. C     IARRAY <--> On output IARRAY is a random permutation of its        
  412. C                 value on input                                         
  413. C                         INTEGER IARRAY( LARRAY )                       
  414. C                                                                        
  415. C     LARRAY <--> Length of IARRAY                                       
  416. C                         INTEGER LARRAY                                 
  417. C                                                                        
  418. C**********************************************************************  
  419. C**********************************************************************  
  420. C                                                                        
  421. C     REAL FUNCTION GENUNF( LOW, HIGH )                                  
  422. C                                                                        
  423. C               GeNerate Uniform Real between LOW and HIGH               
  424. C                                                                        
  425. C                                                                        
  426. C                              Function                                  
  427. C                                                                        
  428. C                                                                        
  429. C     Generates a real uniformly distributed between LOW and HIGH.       
  430. C                                                                        
  431. C                                                                        
  432. C                              Arguments                                 
  433. C                                                                        
  434. C                                                                        
  435. C     LOW --> Low bound (exclusive) on real value to be generated        
  436. C                         REAL LOW                                       
  437. C                                                                        
  438. C     HIGH --> High bound (exclusive) on real value to be generated      
  439. C                         REAL HIGH                                      
  440. C                                                                        
  441. C**********************************************************************  
  442. C**********************************************************************  
  443. C                                                                        
  444. C      SUBROUTINE GETCGN(G)                                              
  445. C                         Get GeNerator                                  
  446. C                                                                        
  447. C     Returns in G the number of the current random number generator     
  448. C                                                                        
  449. C                                                                        
  450. C                              Arguments                                 
  451. C                                                                        
  452. C                                                                        
  453. C     G <-- Number of the current random number generator (1..32)        
  454. C                    INTEGER G                                           
  455. C                                                                        
  456. C**********************************************************************  
  457. C**********************************************************************  
  458. C                                                                        
  459. C     SUBROUTINE GETSD(ISEED1,ISEED2)                                  
  460. C               GET SeeD                                                 
  461. C                                                                        
  462. C     Returns the value of two integer seeds of the current generator    
  463. C                                                                        
  464. C     This  is   a  transcription from  Pascal   to  Fortran  of routine 
  465. C     Get_State from the paper                                           
  466. C                                                                        
  467. C     L'Ecuyer, P. and  Cote,  S. "Implementing a Random Number  Package 
  468. C     with   Splitting Facilities."  ACM  Transactions   on Mathematical 
  469. C     Software, 17:98-111 (1991)                                         
  470. C                                                                        
  471. C                                                                        
  472. C                              Arguments                                 
  473. C                                                                        
  474. C                                                                        
  475. C                                                                        
  476. C     ISEED1 <- First integer seed of generator G                        
  477. C                                   INTEGER ISEED1                       
  478. C                                                                        
  479. C     ISEED2 <- Second integer seed of generator G                       
  480. C                                   INTEGER ISEED1                       
  481. C                                                                        
  482. C**********************************************************************  
  483. C**********************************************************************  
  484. C                                                                        
  485. C     INTEGER FUNCTION IGNBIN( N, P )                                    
  486. C                                                                        
  487. C                    GENerate BINomial random deviate                    
  488. C                                                                        
  489. C                                                                        
  490. C                              Function                                  
  491. C                                                                        
  492. C                                                                        
  493. C     Generates a single random deviate from a binomial                  
  494. C     distribution whose number of trials is N and whose                 
  495. C     probability of an event in each trial is P.                        
  496. C                                                                        
  497. C                                                                        
  498. C                              Arguments                                 
  499. C                                                                        
  500. C                                                                        
  501. C     N  --> The number of trials in the binomial distribution           
  502. C            from which a random deviate is to be generated.             
  503. C                              INTEGER N                                 
  504. C                                                                        
  505. C     P  --> The probability of an event in each trial of the            
  506. C            binomial distribution from which a random deviate           
  507. C            is to be generated.                                         
  508. C                              REAL P                                    
  509. C                                                                        
  510. C     IGNBIN <-- A random deviate yielding the number of events          
  511. C                from N independent trials, each of which has            
  512. C                a probability of event P.                               
  513. C                              INTEGER IGNBIN                            
  514. C                                                                        
  515. C                                                                        
  516. C                              Note                                      
  517. C                                                                        
  518. C                                                                        
  519. C     Uses RANF so the value of the seeds, ISEED1 and ISEED2 must be set 
  520. C     by a call similar to the following                                 
  521. C          DUM = RANSET( ISEED1, ISEED2 )                                
  522. C                                                                        
  523. C                                                                        
  524. C                              Method                                    
  525. C                                                                        
  526. C                                                                        
  527. C     This is algorithm BTPE from:                                       
  528. C                                                                        
  529. C         Kachitvichyanukul, V. and Schmeiser, B. W.                     
  530. C                                                                        
  531. C         Binomial Random Variate Generation.                            
  532. C         Communications of the ACM, 31, 2                               
  533. C         (February, 1988) 216.                                          
  534. C                                                                        
  535. C**********************************************************************  
  536. C**********************************************************************  
  537. C                                                                        
  538. C     INTEGER FUNCTION IGNLGI()                                          
  539. C               GeNerate LarGe Integer                                   
  540. C                                                                        
  541. C     Returns a random integer following a uniform distribution over     
  542. C     (1, 2147483562) using the current generator.                       
  543. C                                                                        
  544. C     This is a transcription from Pascal to Fortran of routine          
  545. C     Random from the paper                                              
  546. C                                                                        
  547. C     L'Ecuyer, P. and Cote, S. "Implementing a Random Number Package    
  548. C     with Splitting Facilities." ACM Transactions on Mathematical       
  549. C     Software, 17:98-111 (1991)                                         
  550. C                                                                        
  551. C**********************************************************************  
  552. C**********************************************************************  
  553. C                                                                        
  554. C     INTEGER FUNCTION IGNPOI( AV )                                      
  555. C                                                                        
  556. C                    GENerate POIsson random deviate                     
  557. C                                                                        
  558. C                                                                        
  559. C                              Function                                  
  560. C                                                                        
  561. C                                                                        
  562. C     Generates a single random deviate from a Poisson                   
  563. C     distribution with mean AV.                                         
  564. C                                                                        
  565. C                                                                        
  566. C                              Arguments                                 
  567. C                                                                        
  568. C                                                                        
  569. C     AV --> The mean of the Poisson distribution from which             
  570. C            a random deviate is to be generated.                        
  571. C                              REAL AV                                   
  572. C                                                                        
  573. C     GENEXP <-- The random deviate.                                     
  574. C                              REAL GENEXP                               
  575. C                                                                        
  576. C                                                                        
  577. C                              Method                                    
  578. C                                                                        
  579. C                                                                        
  580. C     Renames KPOIS from TOMS as slightly modified by BWB to use RANF    
  581. C     instead of SUNIF.                                                  
  582. C                                                                        
  583. C     For details see:                                                   
  584. C                                                                        
  585. C               Ahrens, J.H. and Dieter, U.                              
  586. C               Computer Generation of Poisson Deviates                  
  587. C               From Modified Normal Distributions.                      
  588. C               ACM Trans. Math. Software, 8, 2                          
  589. C               (June 1982),163-179                                      
  590. C                                                                        
  591. C**********************************************************************  
  592. C**********************************************************************  
  593. C                                                                        
  594. C     INTEGER FUNCTION IGNUIN( LOW, HIGH )                               
  595. C                                                                        
  596. C               GeNerate Uniform INteger                                 
  597. C                                                                        
  598. C                                                                        
  599. C                              Function                                  
  600. C                                                                        
  601. C                                                                        
  602. C     Generates an integer uniformly distributed between LOW and HIGH.   
  603. C                                                                        
  604. C                                                                        
  605. C                              Arguments                                 
  606. C                                                                        
  607. C                                                                        
  608. C     LOW --> Low bound (inclusive) on integer value to be generated     
  609. C                         INTEGER LOW                                    
  610. C                                                                        
  611. C     HIGH --> High bound (inclusive) on integer value to be generated   
  612. C                         INTEGER HIGH                                   
  613. C                                                                        
  614. C                                                                        
  615. C                              Note                                      
  616. C                                                                        
  617. C                                                                        
  618. C     If (HIGH-LOW) > 2,147,483,561 prints error message on * unit and   
  619. C     stops the program.                                                 
  620. C                                                                        
  621. C**********************************************************************  
  622. C**********************************************************************  
  623. C                                                                        
  624. C     SUBROUTINE INITGN(ISDTYP)                                          
  625. C          INIT-ialize current G-e-N-erator                              
  626. C                                                                        
  627. C     Reinitializes the state of the current generator                   
  628. C          ISDTYP = -1  => sets the state to its initial seed            
  629. C          ISDTYP =  0  => sets the state to its last (previous) seed    
  630. C          ISDTYP =  1  => sets the state to a new seed 2^w values       
  631. C                              from its last seed                        
  632. C                                                                        
  633. C     This is a transcription from Pascal to Fortran of routine          
  634. C     Init_Generator from the paper                                      
  635. C                                                                        
  636. C     L'Ecuyer, P. and Cote, S. "Implementing a Random Number Package    
  637. C     with Splitting Facilities." ACM Transactions on Mathematical       
  638. C     Software, 17:98-111 (1991)                                         
  639. C                                                                        
  640. C                                                                        
  641. C                              Arguments                                 
  642. C                                                                        
  643. C                                                                        
  644. C     ISDTYP -> The state to which the generator is to be set            
  645. C                                                                        
  646. C                                   INTEGER ISDTYP                       
  647. C                                                                        
  648. C**********************************************************************  
  649. C**********************************************************************  
  650. C                                                                        
  651. C     SUBROUTINE INRGCM()                                                
  652. C          INitialize Random number Generator CoMmon                     
  653. C                                                                        
  654. C                                                                        
  655. C                              Function                                  
  656. C                                                                        
  657. C                                                                        
  658. C     Initializes common area  for random number  generator.  This saves 
  659. C     the  nuisance  of  a  BLOCK DATA  routine  and the  difficulty  of 
  660. C     assuring that the routine is loaded with the other routines.       
  661. C                                                                        
  662. C**********************************************************************  
  663. C**********************************************************************  
  664. C                                                                        
  665. C     INTEGER FUNCTION MLTMOD(A,S,M)                                     
  666. C                                                                        
  667. C                    Returns (A*S) MOD M                                 
  668. C                                                                        
  669. C     This is a transcription from Pascal to Fortran of routine          
  670. C     MULtMod_Decompos from the paper                                    
  671. C                                                                        
  672. C     L'Ecuyer, P. and Cote, S. "Implementing a Random Number Package    
  673. C     with Splitting Facilities." ACM Transactions on Mathematical       
  674. C     Software, 17:98-111 (1991)                                         
  675. C                                                                        
  676. C                                                                        
  677. C                              Arguments                                 
  678. C                                                                        
  679. C                                                                        
  680. C     A, S, M  -->                                                       
  681. C                         INTEGER A,S,M                                  
  682. C                                                                        
  683. C**********************************************************************  
  684. C**********************************************************************  
  685. C                                                                        
  686. C     SUBROUTINE PHRTSD( PHRASE, SEED1, SEED2 )                          
  687. C               PHRase To SeeDs                                          
  688. C                                                                        
  689. C                                                                        
  690. C                              Function                                  
  691. C                                                                        
  692. C                                                                        
  693. C     Uses a phrase (character string) to generate two seeds for the RGN 
  694. C     random number generator.                                           
  695. C                                                                        
  696. C                                                                        
  697. C                              Arguments                                 
  698. C                                                                        
  699. C                                                                        
  700. C     PHRASE --> Phrase to be used for random number generation          
  701. C                         CHARACTER*(*) PHRASE                           
  702. C                                                                        
  703. C     SEED1 <-- First seed for RGN generator                             
  704. C                         INTEGER SEED1                                  
  705. C                                                                        
  706. C     SEED2 <-- Second seed for RGN generator                            
  707. C                         INTEGER SEED2                                  
  708. C                                                                        
  709. C                                                                        
  710. C                              Note                                      
  711. C                                                                        
  712. C                                                                        
  713. C     Trailing blanks are eliminated before the seeds are generated.     
  714. C                                                                        
  715. C     Generated seed values will fall in the range 1..2^30               
  716. C     (1..1,073,741,824)                                                 
  717. C                                                                        
  718. C**********************************************************************  
  719. C**********************************************************************  
  720. C                                                                        
  721. C     REAL FUNCTION RANF()                                               
  722. C                RANDom number generator as a Function                   
  723. C                                                                        
  724. C     Returns a random floating point number from a uniform distribution 
  725. C     over 0 - 1 (endpoints of this interval are not returned) using the 
  726. C     current generator                                                  
  727. C                                                                        
  728. C     This is a transcription from Pascal to Fortran of routine          
  729. C     Uniform_01 from the paper                                          
  730. C                                                                        
  731. C     L'Ecuyer, P. and Cote, S. "Implementing a Random Number Package    
  732. C     with Splitting Facilities." ACM Transactions on Mathematical       
  733. C     Software, 17:98-111 (1991)                                         
  734. C                                                                        
  735. C**********************************************************************  
  736. C**********************************************************************  
  737. C                                                                        
  738. C      SUBROUTINE SETALL(ISEED1,ISEED2)                                  
  739. C               SET ALL random number generators                         
  740. C                                                                        
  741. C     Sets the initial seed of generator 1 to ISEED1 and ISEED2. The     
  742. C     initial seeds of the other generators are set accordingly, and     
  743. C     all generators states are set to these seeds.                      
  744. C                                                                        
  745. C     This is a transcription from Pascal to Fortran of routine          
  746. C     Set_Initial_Seed from the paper                                    
  747. C                                                                        
  748. C     L'Ecuyer, P. and Cote, S. "Implementing a Random Number Package    
  749. C     with Splitting Facilities." ACM Transactions on Mathematical       
  750. C     Software, 17:98-111 (1991)                                         
  751. C                                                                        
  752. C                                                                        
  753. C                              Arguments                                 
  754. C                                                                        
  755. C                                                                        
  756. C     ISEED1 -> First of two integer seeds                               
  757. C                                   INTEGER ISEED1                       
  758. C                                                                        
  759. C     ISEED2 -> Second of two integer seeds                              
  760. C                                   INTEGER ISEED1                       
  761. C                                                                        
  762. C**********************************************************************  
  763. C**********************************************************************  
  764. C                                                                        
  765. C      SUBROUTINE SETANT(QVALUE)                                         
  766. C               SET ANTithetic                                           
  767. C                                                                        
  768. C     Sets whether the current generator produces antithetic values.  If 
  769. C     X   is  the value  normally returned  from  a uniform [0,1] random 
  770. C     number generator then 1  - X is the antithetic  value. If X is the 
  771. C     value  normally  returned  from a   uniform  [0,N]  random  number 
  772. C     generator then N - 1 - X is the antithetic value.                  
  773. C                                                                        
  774. C     All generators are initialized to NOT generate antithetic values.  
  775. C                                                                        
  776. C     This is a transcription from Pascal to Fortran of routine          
  777. C     Set_Antithetic from the paper                                      
  778. C                                                                        
  779. C     L'Ecuyer, P. and Cote, S. "Implementing a Random Number Package    
  780. C     with Splitting Facilities." ACM Transactions on Mathematical       
  781. C     Software, 17:98-111 (1991)                                         
  782. C                                                                        
  783. C                                                                        
  784. C                              Arguments                                 
  785. C                                                                        
  786. C                                                                        
  787. C     QVALUE -> .TRUE. if generator G is to generating antithetic        
  788. C                    values, otherwise .FALSE.                           
  789. C                                   LOGICAL QVALUE                       
  790. C                                                                        
  791. C**********************************************************************  
  792. C**********************************************************************  
  793. C                                                                        
  794. C     SUBROUTINE SETCGN( G )                                             
  795. C                      Set GeNerator                                     
  796. C                                                                        
  797. C     Sets  the  current  generator to G.    All references to a generato
  798. C     are to the current generator.                                      
  799. C                                                                        
  800. C                                                                        
  801. C                              Arguments                                 
  802. C                                                                        
  803. C                                                                        
  804. C     G --> Number of the current random number generator (1..32)        
  805. C                    INTEGER G                                           
  806. C                                                                        
  807. C**********************************************************************  
  808. C********************************************************************** 
  809. C                                                                       
  810. C     SUBROUTINE SETGMN( MEANV, COVM, P, PARM)                          
  811. C            SET Generate Multivariate Normal random deviate            
  812. C                                                                       
  813. C                                                                       
  814. C                              Function                                 
  815. C                                                                       
  816. C                                                                       
  817. C      Places P, MEANV, and the Cholesky factoriztion of COVM           
  818. C      in GENMN.                                                        
  819. C                                                                       
  820. C                                                                       
  821. C                              Arguments                                
  822. C                                                                       
  823. C                                                                       
  824. C     MEANV --> Mean vector of multivariate normal distribution.        
  825. C                                        REAL MEANV(P)                  
  826. C                                                                       
  827. C     COVM   <--> (Input) Covariance   matrix    of  the  multivariate  
  828. C                 normal distribution                                   
  829. C                 (Output) Destroyed on output                          
  830. C                                        REAL COVM(P,P)                 
  831. C                                                                       
  832. C     P     --> Dimension of the normal, or length of MEANV.            
  833. C                                        INTEGER P                      
  834. C                                                                       
  835. C     PARM <-- Array of parameters needed to generate multivariate norma
  836. C                deviates (P, MEANV and Cholesky decomposition of       
  837. C                COVM).                                                 
  838. C                1 : 1                - P                               
  839. C                2 : P + 1            - MEANV                           
  840. C                P+2 : P*(P+3)/2 + 1  - Cholesky decomposition of COVM  
  841. C                                             REAL PARM(P*(P+3)/2 + 1)  
  842. C                                                                       
  843. C********************************************************************** 
  844. C**********************************************************************  
  845. C                                                                        
  846. C     SUBROUTINE SETSD(ISEED1,ISEED2)                                    
  847. C               SET S-ee-D of current generator                          
  848. C                                                                        
  849. C     Resets the initial seed and state of generator g to ISEED1 and     
  850. C     ISEED2. The seeds and states of the other generators  remain       
  851. C     unchanged.                                                         
  852. C                                                                        
  853. C     This is a transcription from Pascal to Fortran of routine          
  854. C     Set_Seed from the paper                                            
  855. C                                                                        
  856. C     L'Ecuyer, P. and Cote, S. "Implementing a Random Number Package    
  857. C     with Splitting Facilities." ACM Transactions on Mathematical       
  858. C     Software, 17:98-111 (1991)                                         
  859. C                                                                        
  860. C                                                                        
  861. C                              Arguments                                 
  862. C                                                                        
  863. C                                                                        
  864. C     ISEED1 -> First integer seed                                       
  865. C                                   INTEGER ISEED1                       
  866. C                                                                        
  867. C     ISEED2 -> Second integer seed                                      
  868. C                                   INTEGER ISEED1                       
  869. C                                                                        
  870. C**********************************************************************  
  871.